<%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2024/8/9
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
    <form id="formId"  method="post">
        用户名：<input type="text" name="name"><br>
        用户名：<input type="password" name="password"><br>
        验证码：<input type="text" name="code"> <img src="/verifyCode"><br>
        <input type="button" onclick="submitForm()" value="登录">
    </form>
    <script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <script>
        function submitForm() {
            $.post(
                '/user?method=login',
                $('#formId').serialize(), //{"name":"zhangsan","password":"123"}
                function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        mylayer.okUrl(result.msg, '/');
                    } else {
                        mylayer.errorMsg(result.msg);
                    }
                },
                'json'
            );
        }

    </script>
</body>
</html>
